<script>
  const nums = [11, 22, 38, 1, 8];
  const newNums = new Set(nums);
  if (newNums.has(11)) {
    console.log("存在");
  } else {
    console.log("不存在");
  }

  const arr1 = [1, 22, 38, 31, 18];
  const arr2 = [1, 122, 138, 19, 8];
  const setArr1 = new Set(arr1);
  const setArr2 = new Set(arr2);

  const union = new Set([...setArr1, ...setArr2]);

  const intersection = new Set(
    [...setArr1].filter((item) => setArr2.has(item))
  );

  const difference = new Set([...setArr1].filter((item) => !setArr2.has(item)));

  const alignment = new Set();
  alignment.add(10);
  alignment.add(11);
  alignment.add(12);
  alignment.add(15);
  alignment.delete(alignment.values().next().value);
  console.log(alignment);

  const stack = new Set();
  stack.add(10);
  stack.add(11);
  stack.add(12);
  stack.add(15);
  stack.delete([...stack][stack.size - 1]);
  console.log(stack);

  const data = [1, 2, 3, 4];
  const squareArr = data.map((item) => {
    return item * item;
  });

  const numArr = [1, 2, 3, 4, 5, 6, 7];
  const doubles = (nums) =>
    nums.map((item) => (item % 2 === 1 ? item * 2 : item));
  console.log(doubles(numArr));

  const users = [
    {
      id: 1,
      name: "坤一",
    },
    {
      id: 2,
      name: "坤二",
    },
    {
      id: 3,
      name: "坤三",
    },
    {
      id: 4,
      name: "坤四",
    },
    {
      id: 5,
      name: "坤五",
    },
  ];

  const userList = users.map(item => item.name)
  console.log(userList);
</script>
